package com.lfnyxy.service.imp;


import com.lfnyxy.dao.ClientDao;
import com.lfnyxy.dto.DropVo;
import com.lfnyxy.entity.ClientEntity;
import com.lfnyxy.query.ClientQuery;
import com.lfnyxy.service.ClientService;
import com.lfnyxy.vo.ProductVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClientServiceImp implements ClientService {
    @Autowired
    public ClientDao clientDao;

    public int CreateItem(ClientEntity entity) {
        if (entity != null) {
            return clientDao.CreateItem(entity);
        } else {
            return 0;
        }
    }

    public int UpdateItem(ClientEntity entity) {
        if (entity != null) {
            return clientDao.UpdateItem(entity);
        } else {
            return 0;
        }
    }

    public List<ProductVo> QueryPageList(ClientQuery query) {
        int count = clientDao.QueryPageListCount(query);
        query.setTotal(count);
        return clientDao.QueryPageList(query);
    }

    public List<ClientEntity> QueryAll() {
        return clientDao.QueryAll();
    }

    public  List<DropVo> QueryDrop(ClientQuery query){
        return clientDao.QueryDrop(query);
    }

    public ClientEntity QueryItem(int Id) {
        if (Id > 0) {
            return clientDao.QueryItem(Id);
        } else {
            return null;
        }
    }

    public int DeleteItem(int Id) {
        if (Id > 0) {
            return clientDao.DeleteItem(Id);
        } else {
            return 0;
        }
    }



    private boolean CheckIsExist(ClientEntity entity) {
        if (entity != null) {
            return clientDao.CheckIsExist(entity) > 0;
        } else {
            return false;
        }
    }
}